CC := gcc`

CFLAGS := -Wall -Iinclude

LIBDIR := lib

SRCDIR := src

INCDIR := include

TARGET := main
OBJS := $(LIBDIR)/add.o $(LIBDIR)/sub.o

LIBRARY := $(LIBDIR)/libcal.a
all: $(TARGET)
$(TARGET): main.c $(LIBRARY)
$(CC) $(CFLAGS) -o $@ $< -L$(LIBDIR) -lcal
$(LIBRARY): $(OBJS)
ar rcs $@ $^
$(LIBDIR)/%.o: $(SRCDIR)/%.c | $(LIBDIR)
$(CC) $(CFLAGS) -c -o $@ $<
$(LIBDIR):
	mkdir -p $@
clean:
	rm -rf $(LIBDIR) $(TARGET)
.PHONY: all clean

